package com.mmall.concurrency.example.singleton;

import com.mmall.concurrency.annoations.ThreadSafe;

/**
 * 饿汉模式
 * 单例实例在类加载时进行创建
 */

@ThreadSafe
public class SingletonExample2 {

    //私有构造函数
    private SingletonExample2()
    {

    }

    //单例对象
    private static SingletonExample2 singleton = new SingletonExample2();

    // 静态的工厂方法
    public static SingletonExample2 getSingleton() {
        return singleton;
    }
}
